{extend name="public:base" /}
{block name="content"}

<div class="page-header">
	<h1>	
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb2}
		</small>
	</h1>
</div>
<div class="page-header">
	{if condition="$Request.param.pid"}
		<a href="{:url('Category/add',array('pid'=>input('param.pid')))}" class="btn btn-primary">新增</a>
	{else/}
		<a href="{:url('Category/add')}" class="btn btn-primary">新增</a>
	{/if}
</div>	
	
<div class="row">
	<div class="col-xs-12">	
		<div class="table-responsive">
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th>排序</th> 		
						<th>图片</th> 									
						<th>分类名称</th>					
						<th>操作</th>				
					</tr>
				</thead>
				<tbody>
					{volist name="list" id="cat" empty="$empty"}
					<tr>
						<td>
							<input name="sort" type="text" size="1" class="sort" cid='{$cat.id}' value="{$cat.sort_order}" />								
						</td>
						<td>
							<a href="{:url('Category/index',array('pid'=>$cat['id']))}">
								{if condition="$cat['image']"}
		                  			<img src="IMG_ROOT{$cat.image|resize=50,50}" />
			                  	{else /}
			                  		<img src="__PUBLIC__/image/no_image_50x50.jpg" />
			                  	{/if}
		                  	</a>
						</td>
						<td>
							<a href="{:url('Category/index',array('pid'=>$cat['id']))}">
							{$cat.name}
							</a>
						</td>
						<td>
							<a  class="btn btn-xs btn-info" href='{:url("category/edit",array("id"=>$cat["id"]))}'>
								<i class="fa fa-edit bigger-120"></i>
							</a> 
							<a class="delete btn btn-xs btn-danger" href='{:url("category/del",array("id"=>$cat["id"]))}' >
								<i class="fa fa-trash bigger-120"></i>
							</a>
						</td>
					</tr>	
					{/volist}
					
					<tr>
						<td colspan="20" class="page">{$list->render()}</td>
					</tr>
					<tr>
						<td colspan="20">总计 {$list->total()|default="0"} 个分类</td>
					</tr>	
				</tbody>
				
			</table>
		</div>
	</div>
</div>
{/block}
{block name="javascript"}
<script>
$('.sort').blur(function(){
		
		$.post(
			"{:url('Category/update_sort')}",
			{sort:$(this).val(),cid:$(this).attr('cid')},
			function(data){
				if(data){
					window.location.reload();
				}
			}
		);
	});
</script>
{/block}